package com.app.ryjy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 转移状态枚举
 */
@AllArgsConstructor
@Getter
public enum TransferStatusEnum {
    // 未转移
    NOT_TRANSFERRED("未转移", "0"),
    // 已转移
    TRANSFERRED("已转移", "1"),
    // 转出返乡
    TRANSFERRED_BACK_HOME("转出返乡", "2");

    private final String desc;
    private final String code;

    /**
     * 根据 code 获取 desc
     *
     * @param code code
     * @return desc
     */
    public static String getDescByCode(String code) {
        for (TransferStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status.getDesc();
            }
        }
        throw new RuntimeException("code 不存在");
    }

    public static void main(String[] args) {
        System.out.println(TransferStatusEnum.getDescByCode("1"));  // 输出：已转移
    }
}
